package com.info.zhiduoduo.repository.mapper.recharge;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.recharge.RechargeRecordDto;
import com.info.zhiduoduo.repository.entity.recharge.RechargeRecord;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author tianyonghong
 * @create 2021/12/9
 */
public interface RechargeRecordMapper extends BaseMapper<RechargeRecord> {

    @Select(" select rec.*,sm.managername as createdName,type.recharge_type_name,type.recharge_standard from zdd_recharge_record rec" +
            " left join zdd_recharge_type type on rec.recharge_type_id = type.recharge_type_id " +
            " left join zdd_system_manager sm on sm.managerid = rec.created_by " +
            " where IF(ISNULL(#{customerName}) or #{customerName}='',1=1,rec.customer_name like '%${customerName}%') " +
            " and IF(ISNULL(#{customerType}),1=1,rec.customer_type = #{customerType}) " +
            " and IF(ISNULL(#{startTime}),1=1,rec.recharge_time >= #{startTime})" +
            " and IF(ISNULL(#{endTime}),1=1,rec.recharge_time <= #{endTime})" +
            " order by rec.created_time desc ")
    List<RechargeRecordDto> queryRechargeRecordList(String customerName, Integer customerType, Date startTime, Date endTime);
}

